//-----------------------------------------------
//-      - Define a 2D vector 
//-----------------------------------------------

/* These defines allow the header to be included more than once
in the same file */

#ifndef __IGU_VEC2__
#define __IGU_VEC2__

#include <vector> // STL vector

struct Vec2
{
	// Vec2 Constructor 
	Vec2(float x = 0.0f, float y = 0.0f);

	// Adds v to this vector
	// see note [1]
	void add(const Vec2 &v);

	// Subtract v from this vector (this = this - v)
	// see note [1]
	void subtract(const Vec2 &v);

	// Returns the length of the vector
	float length() const; // <- this const is important. See note [2]

	// Member variables 
	float x;
	float y;
};

// Definition of a vector of Vec2 elements:
typedef std::vector< Vec2 > VectorVec2;

/* Notes:
	[1] - The functions that receive a Vec2 object, but *DO NOT* 
	modify it, should always define that argument as
	
		-->    const Vec2 &parameter    <--
	
	This allows the compiler to pass a constant reference to the function, 
	without unnecessarily copying the object.

	[2] - *ALL* the Vec2 methods that *DO NOT* change the state of the object
	(i.e., write to the member variables) should add the "const" keyword at 
	the end, to let the compiler (and the user of the library) know that 
	that funcion will not modify the object. For example, to compute the length 
	of a 2D vector, its coordinates are not changed.

*/

#endif
